<link rel="stylesheet" type="text/css" href="/site_media/css/Title_white.css" /><link href="/media/css/jquery.wysiwyg.css" rel="stylesheet" type="text/css" />
<link href="/media/css/form.css" rel="stylesheet" type="text/css" />
<link href="/media/css/Title_white.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


function uncheckRadio() {
 var choice = document.form1.client;
 for (i = 0; i < choice.length; i++) {
  if ( choice[i].checked = true ) 
   choice[i].checked = false; 
 }
}

</script>



{% extends 'base.html' %}
{% block title %} - New Project{% endblock %}

{% block js %}
<script type="text/javascript" src="/site_media/js/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="/site_media/js/jquery.wysiwyg.js"></script>
<link rel="stylesheet" href="/site_media/css/jquery.wysiwyg.css" type="text/css" />
<script type="text/javascript">
	$(function()
	{
		$('#wysiwyg').wysiwyg();
	});
</script>
{% endblock %}

{% block onload %}
onload="document.getElementById('p_name').focus();"
{% endblock %}

{% block content %}

<script>
	var cids = new Array();
	var youtube_moods = new Array();

	function showlayer(name){
		var subitem=document.getElementById(name+"_layer");
		if(subitem.style.display=='none'){
			subitem.style.display='';
		}else{
			subitem.style.display='none';
		}
	}

	function add_moods(){
		var str = document.getElementById("youtube").value;
		if (str=="") return false;
		var s = str.split('&');
		var sid = s[0].split("v=");

		for (var i=0;i<youtube_moods.length;i++){
			if (youtube_moods[i] == sid[1]) return false
		}
		youtube_moods.push(sid[1]);
		i_html= "<input type=\"checkbox\" checked=\"true\" name=\"moods\" value=\""+
			sid[1]+"\" /><a href='"+s[0]+"'>YouTube_"+[i]+"</a><br/>";

		document.getElementById('mood_div').innerHTML +=  i_html;
		return false;
	}

	/* Check whether fhr form is valid, name has been inputed. */
	function check_form(_form){
		if (_form.p_name.value == ""){
			alert("Please input project name!");
			_form.p_name.focus();
			return false;
		}
	/* This is something wron with this. */	
		var obj=document.getElementsByName('client');
		for(i=0;i<obj.length;i++){
			if(true){
				return true;
			}
		}

		if(_form.username.value==''){
			alert("Please input user name!");
			_form.username.focus();
			return false;
		}

		if(_form.email.value==''){
			alert("Please input email address!");
			_form.email.focus();
			return false;
		}

		if(_form.pwd.value==''){
			alert("Please input password!");
			_form.pwd.focus();
			return false;
		}
		
		return true;
	}
</script>
<div id="content" style="position:absolute; top:20px; left:0px; width:610px; height:relative; background-color: #1A1A1A; layer-background-color: #1A1A1A; border: 1px none #000000;">


<form name="form1" enctype="multipart/form-data" method="post" action="/project/new/" onsubmit="return check_form(this);">
	

<table width="610">
	<tr>
	<td colspan="2"><p><span style="font-size:14px;color:#CCC">Create new project</span></p></td>
	</tr>
		<tr>
			<td>Project title <br/>
            <input name="p_name" id="p_name" type="text"></td></tr>
			<tr><td>Brand <br/>
            <input name="p_brand" id="p_brand" type="text"></td></tr>
        	<td>City <br/>
            <input name="p_city" id="p_city" type="text"></td>
        </tr>
		<tr>
			<td colspan="3">Description</td>
	  </tr>
		<tr>
			<td colspan="3"><textarea name="description" id="wysiwyg" rows="10" cols="70">Thank you for letting us pitch on this great Job!</textarea></td>
		</tr>
		
	
<tr>
			<td>Select client
  </td>
            <td><a href="javascript:;" onclick="MM_showHideLayers('new_client','','show')">Create new client </a><a href="javascript:;" onclick="MM_showHideLayers('new_client','','hide')"> (Hide)</a><br/>
  </td></tr>
            <tr><td> 
           
       		<select name="client"> <option value="" selected="true">-----</option>
            {% for client in clients %}
            <option name="client_id" value="{{client.id}}">{{client.first_name}} - <a href="mailto:{{client.email}}">{{client.email}}</a> <br> </option>
            {% endfor %}
  
        	</select>

                 </td>
                
         
                <td><div id="new_client" style="position:absolution;margin-left:10px;visibility:hidden">
  <table>
    <tr><td>Username:</td><td> <input name="username" type="text" onKeyDown="uncheckRadio();"/> </td></tr>
    <tr><td>Password:</td><td> <input name="pwd" type="password" /></td></tr>
    <tr><td>Company:</td><td> <input name="company" type="text" /></td></tr>
    <tr><td>Email:</td><td> <input name="email" type="text" /></td></tr>
    
  </table>
                </div>
                    
	    </td></tr>
		<tr>
			<td><FORM><INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"></FORM></td>
			<td align="right"><input type="submit" value="Create"/></td></tr>
	</table>

</form>

</div>


{% endblock %}
